﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SdmxMl.GenericData;
using SdmxMl.Manager;
using SdmxMl.Structure;

namespace SdmxMl.UC
{
    public partial class UcDatasetType : UserControl
    {
        protected TreeNode treeNode;
        private DataSetType dataSet;
        
        public UcDatasetType()
        {
            InitializeComponent();
        }

        public virtual void BindFromNode(TreeNode node)
        {
            treeNode = node;
            dataSet = null;
            if (node != null)
            {
                dataSet = node.Tag as DataSetType;

            }
            BindToControls();

        }

        private void BindToControls()
        {
            if (dataSet != null)
            {
                ucEditReference1.AtrefactType = SdmxArtefactType.KeyFamilies;
                ucEditReference1.ArtefactRef = dataSet;
                Visible = true;
            }
            else
                Visible = false;
        }

        public bool UpdateNodeTag(TreeNode node)
        {
            bool err = false;
            if (node != null)
            {
                err = BindFromControls();
                if (dataSet != null && node.Text != dataSet.ToString())
                    node.Text = dataSet.ToString();
            }

            return err; // true on error
        }

        protected bool BindFromControls()
        {
            bool err = false;
            if (dataSet != null)
            {
              //  metaSet.Name.UpdateForCurrentLanguage(comboBoxTitle.Text);

            }
            return err;
        }

    }
}
